'use strict';

// 随机10题进行答题
exports.main = async (event, context) => {
	//event为客户端上传的参数
	const db = uniCloud.database();
	const dbCmd = db.command // 取指令
	// 1.判断题 2.单选 3.多选
	let res = await db.collection('collection_subject').aggregate()
		.match({
			type: dbCmd.in(['1', '2', '3']), // 查询匹配的字段值数据
			isSubject: true
		})
		.sample({
			size: 10
		})
		.end()

	//返回数据给客户端
	return {
		code: '1',
		msg: 'success',
		data: res.data
	}
};
